IF EXISTS (SELECT * FROM sysobjects WHERE type = 'V' AND name = 'VW_MailboxFetch')
	BEGIN
		DROP  View VW_MailboxFetch
	END
GO

CREATE View VW_MailboxFetch AS

SELECT
	m.MailboxId, m.ServiceId, s.AccountId, m.Password,
	a.Title AS AccountTitle, s.Title, s.CreateDate, s.UpdateDate
FROM Mailboxes AS m
INNER JOIN Services AS s ON m.ServiceId = s.ServiceId
INNER JOIN Accounts AS a ON s.AccountId = a.AccountId

GO